

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加角色</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${basePath!}/genius/layui/css/layui.css" media="all">
</head>
<body>

  <div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    
    <div class="layui-form-item">
      <label class="layui-form-label">上级菜单</label>
      <div class="layui-input-inline" id="nameTree">
        <input type="text" name="roleId" style="display:none"  lay-verify="required" lay-filter="nameTree" placeholder="上级菜单" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">角色名称</label>
      <div class="layui-input-inline" >
         <input type="text" name="name" lay-verify="required"  placeholder="请输入角色名称" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">状态</label>
      <div class="layui-input-inline">
        <input type="checkbox" lay-filter="switch" name="status" checked="true" lay-skin="switch" lay-text="启用|禁用">
      </div>
    </div>
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="LAY-role-add-submit" id="LAY-role-add-submit" value="确认">
    </div>
  </div>

  <script src="${basePath!}/genius/layui/layui.js"></script>  
  <script>
  layui.config({
    base: '${basePath!}/genius/' //静态资源所在路径
    ,host:'${basePath!}'//项目访问路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form','xmSelect'], function(){
    var $ = layui.$
    ,form = layui.form
    ,setter = layui.setter
    ,laydate = layui.laydate
    ,xmSelect = layui.xmSelect;
    var RoleSelect = xmSelect.render({
		el: '#nameTree', 
		autoRow: true,
		radio: true,
		clickClose: true,
		tree: {
			show: true,
			showFolderIcon: true,
			showLine: true,
			strict: false,
			indent: 20,
			expandedKeys: [ -1 ],
		},
		height: 'auto',
		on: function(data){
			if(data.isAdd){
				$('#nameTree').find("input[name=roleId]").val(data.change[0].value);
			}
		}
	});
    $.ajax({
  	  url: setter.host+'/adminmanager/role/queryTreeList'
        ,type:'get'
        ,dataType:'json'
        ,success: function(res){
          //请求成功后
          if(res.status==1000){
        	  window.location.href = setter.host+'error/toNoPower?msg='+res.msg+'';
          }else{
        	  RoleSelect.update({
  	    		data: res.data,
  	    		autoRow: true,
      		})
          }
        }
    });
  })
  </script>
</body>
</html>